<template>
	<iframe id="mapPage" width="100%" height="100%" frameborder=0
		:src="'https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=F42BZ-IPPK5-JFNIV-I3YUW-VPTIJ-5KFKY&referer=贷款&mapdraggable=0&policy=1&coord='+coord">
	</iframe>
</template>

<script module='test' lang="renderjs">
	export default {
		data() {
			return {
				locationInfo: {},
				coord: ''
			}
		},
		mounted() {
			let _this = this
			window.addEventListener('message', function(event) {
				// 接收位置信息，用户选择确认位置点后选点组 件会触发该事件，回传用户的位置信息
				var loc = event.data;
				if (loc && loc.module == 'locationPicker') { //防止其他应用也会向该页面post信息，需判断module是否为'locationPicker'
					// console.log('location', loc);
					_this.locationInfo = loc
					_this.emitData()
				}
			}, false);
		},
		methods: {
			emitData(e, ownerVm) {
				this.$ownerInstance.callMethod('receiveRenderData', this.locationInfo)
			}
		}
	}
</script>
<script>
	export default {
		methods: {
			async receiveRenderData(val) {
				console.log('renderjs返回的值-->', val);
				if (val) {
					this.$store.commit('setaddr', val)
					uni.navigateBack()
				}
			}
		},
		onLoad(o) {
			this.coord = o.latitude + ',' + o.longitude
		}
	}
</script>
<style>
	page {
		height: 100%;
	}
</style>